import xlwt


def excel_write(items, index, ws):
    # 爬取到的内容写入excel表格\
    for item in items:  # 电影信息
        for i in range(0, 6):
            # print( item[i])
            ws.write(index, i, item[i])  # 行，列，数据
            # print('index',index)
        index += 1


def data_write(data):
    newTable = "moviedata.xls"  # 表格名称
    wb = xlwt.Workbook(encoding='utf-8')  # 创建excel文件，声明编码
    ws = wb.add_sheet('movieData')  # 创建表格
    headData = ['排名', '影片名称', '导演', '评语', '评分', '电影详情URL']  # 表头部信息
    for colnum in range(0, 6):
        ws.write(0, colnum, headData[colnum], xlwt.easyxf('font: bold on'))  # 行，列
    excel_write(data, 1, ws)
    wb.save(newTable)
